`<template>
  <div
    v-loading="loadingState"
    id="app"
    :style="{ overflow: loadingState ? 'hidden' : 'auto' }"
  >
    <router-view />
  </div>
</template>

<script>
import { mapState, mapActions, mapMutations } from "vuex";
import * as types from "@/store/types";

/* eslint-disable */
export default {
  name: "App",
  data() {
    return {
      route: this.$route,
      isPc: null,
      num: 0,
      src: null
    };
  },
  created() {},
  mounted() {
    // this.ruoterJump({ name: "loading" });
    console.log(window.history, "window.history++");
    let _loginData = JSON.parse(localStorage.getItem("loginData"));
    console.log(_loginData, "_loginData=========");
    if (window.history && window.history.pushState) {
      history.pushState(null, null, document.URL);
      window.addEventListener("popstate", this.goBack, false);
    }

    if (window.location.hash !== "#/agreement") {
      if (_loginData && Object.keys(_loginData).length) {
        this.ruoterJump({ name: "loading" });
      } else {
        this.ruoterJump({ name: "login" });
      }
    }
  },
  computed: {
    ...mapState(["lang", "token", "loadingState"])
  },

  destroyed() {
    window.removeEventListener("popstate", this.goBack, false);
  },
  methods: {
    ...mapMutations({
      setLanguage: types.SET_LANGUAGE // 设置语言包
    }),
    setLanguageLayout() {
      // 此功能 保留， 不维护。
      this.num++;
      if (this.num % 2 === 0) {
        this.setLanguage("en"); // 设置语言格式（英语）
      } else {
        this.setLanguage("zh"); // 设置语言格式 (中文)
      }
    },
    goBack() {
      if (this.$route.name) {
        this.ruoterJump({ name: this.$route.name });
      }
    },
    ...mapActions(["ruoterJump"]),
    routerGo() {}
  }
};
</script>
<style lang="less">
#app {
  height: 100%;
}
</style>

<style></style>
